/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fpt.stub;

import edu.fpt.entity.Room;
import edu.fpt.session.RoomFacadeLocal;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author TuanAnh
 */
public class RoomStub {

    RoomFacadeLocal room = lookupRoomFacadeLocal();

    public List<Room> getRoomType() {
        return room.findAll();
    }

    public void updateRoom(Room rom) {
        room.edit(rom);
    }
    
    public int getPrice(String id){
        return room.getPrice(id);
    }

    private RoomFacadeLocal lookupRoomFacadeLocal() {
        try {
            Context c = new InitialContext();
            return (RoomFacadeLocal) c.lookup("java:global/ProjectManagementHotel/ProjectManagementHotel-ejb/RoomFacade!edu.fpt.session.RoomFacadeLocal");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
}
